'use strict';
angular.module('clientApp')


/**
 * @ngdoc function
 * @name clientApp.controller:MainCtrl
 * @description
 * # MainCtrl
 * Controller of the clientApp
 */
.controller('MainCtrl', function ($scope, $filter, panelAPI, ngToast, $interval) {
	
	$scope.tauxRefresh = 30*1000; // 30 secondes
	
	$scope.refresh = function() {
		panelAPI.getToDisplay()
		.success(function(data) {
			$scope.panneau = data;
		})
		.error(function() {
			ngToast.create({
				content: 'Erreur de communication avec le serveur',
				className: 'danger'
			});
		});
	};
	$scope.refresh();
	
	$interval(function(){
		$scope.refresh();
	}, $scope.tauxRefresh);
});

